﻿using System;
using NUnit.Framework;
using NBehave.Spec.NUnit;
using SilverlightCalculator.CalculatorValidationRules;

namespace SilverlightCalculator.Tests.CalculatorValidationRules
{
    [TestFixture]
    public class When_validating_value_is_a_number
    {
        [Test]
        public void Should_return_false_when_value_is_not_a_number()
        {
            // Arrange
            var validateValueIsANumber = new ValidateValueIsANumber();

            // Act
            var result = validateValueIsANumber.IsValid("AAA");

            // Assert
            result.ShouldBeFalse();
        }

        [Test]
        public void Should_return_true_when_value_is_a_number()
        {
            // Arrange
            var validateValueIsANumber = new ValidateValueIsANumber();

            // Act
            var result = validateValueIsANumber.IsValid("99");

            // Assert
            result.ShouldBeTrue();
        }

        [Test]
        public void Should_return_true_when_value_null()
        {
            // Arrange
            var validateValueIsANumber = new ValidateValueIsANumber();

            // Act
            var result = validateValueIsANumber.IsValid(null);

            // Assert
            result.ShouldBeTrue();
        }

        [Test]
        public void Should_return_true_when_value_is_empty()
        {
            // Arrange
            var validateValueIsANumber = new ValidateValueIsANumber();

            // Act
            var result = validateValueIsANumber.IsValid(String.Empty);

            // Assert
            result.ShouldBeTrue();
        }
    }
}